#include "Alice/Systems/VisualBoxSys.h"
#include "Alice/Components/TransformComp.hpp"
#include "Alice/Components/OBBComp.hpp"
#include "Alice/Core/World.h"

namespace Alice
{

void VisualBoxSys::Before()
{
    m_brush.Init();
}

void VisualBoxSys::OnUpdate()
{
    for (auto entity : entitys)
    {
        TransformComp& tf_comp = world->GetComp<TransformComp>(entity);
        OBBComp& obb_comp = world->GetComp<OBBComp>(entity);

        m_brush.DrawRect(
            m_window_info,
            tf_comp.position.x,
            tf_comp.position.y,
            obb_comp.width,
            obb_comp.height,
            tf_comp.rotate
        );
    }
}

void VisualBoxSys::After()
{
    m_brush.Destroy();
}

} // namespace Alice
